<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>项目编号生成</title>
  <link rel="stylesheet" href="/plug-in/layui/css/layui.css" media="all">
</head>
<body style="padding:5px;">

<form class="layui-form" action="#">
	<div class="layui-form-item">
	    <div class="layui-inline">
	      <label class="layui-form-label">项目编号</label>
	      <div class="layui-input-inline" style="width: 150px;">
	        <input type="text" name="p1" placeholder="项目编号" autocomplete="off" class="layui-input" />
	      </div>
	      <div class="layui-form-mid">-</div>
	      <div class="layui-input-inline" style="width: 200px;">
	         <select  name="p2" id="designUnit"></select>
	      </div>
	    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
     	<button class="layui-btn" data-type="01">刷新</button>
	  	<button class="layui-btn" lay-submit lay-filter="*">确认选择</button>
    </div>
  </div>
</form>
<script src="/plug-in/layui/layui.js"></script>
<script>
layui.config({ base: '/plug-in/build/'}).use(['layer','jquery','pData','form','util'], function(){
	var table = layui.table;
	var $ = layui.jquery;
	var layer = layui.layer;
	var pData = layui.pData;
	var form = layui.form;
	var util = layui.util;
    /*按钮活动响应*/
    var active = {
	  reload: function(){
		  var p1= util.toDateString(new Date(), 'yyyyMMddHHmm');
		  $("input[name=p1]").val(p1.slice(2));
		  return;
	  },
	  close: function(){
		  var index = parent.layer.getFrameIndex(window.name);
		  parent.layer.close(index);
	  }
 	 };
    
    active.reload();
    
    pData.select([
       {target:'#designUnit', valueField:'dicValue',textField:'dicName',url:'/console/dictionary/combobox?pCode=B5&pCode_searchType=eq'}
    ]);
    
    //var autoCode = parent.autoCode;
    form.on('submit(*)', function(data){
   	  	var pNo = data.field.p1 + data.field.p2;
   	  	if(data.field.p2==''){
   	  		layer.msg('未指定编号后缀!', { icon: 6 });
   	  		return false;
   	  	}
   	 	parent.autoCode(pNo);
   		active.close();
   	  	return false;
   	});
   
   $('button').on('click', function(){
	   	var $btn = $(this);
		switch ($btn.attr("data-type")) {
	  	case "01":
	  		active.reload();
		  break;
		default: break;
	  }
 	});
});
</script>
</body>
</html>